import { request } from "./base";
import type { FILE_TYPE } from "@/utils/enums";

export interface SignParams {
  fileType: FILE_TYPE;
  type: string; // 文件业务类型
  method: "PUT";
  fileName: string;
}

export interface OssSignResult {
  sign: {
    object: string[]; // 相对路径数组
    signUrl: string[]; // oss路径数组
  };
}

/** 获取oss签名 */
export const fetchOssSign = (data: SignParams) => {
  return request<OssSignResult>({
    url: "/pc/upload/getOssFileSign",
    method: "POST",
    data,
  });
};

/** 检测上传到oss的文件 */
export function fetchCheckOssFile(data: { object: string }) {
  return request<{ object: string[] }>({
    url: "/pc/upload/checkOssFile",
    method: "POST",
    data,
  });
}
